//饿汉式单例,一开始就要初始化好
#include<mutex>
#include<iostream>
#include<memory>
class Singleton{
public:
    static Singleton& GetInstance(){
            return *_instance;
    }
    void operator=(const Singleton&)=delete;
     Singleton(const Singleton&) = delete; // 禁止复制构造函数

private:
    Singleton(){}                       
    static std::unique_ptr<Singleton> _instance;

};

std::unique_ptr<Singleton> Singleton::_instance(new Singleton());

int main()
{
    Singleton& s1= Singleton::GetInstance();
    Singleton& s2 =Singleton::GetInstance();
    //两个对象是不能直接用==的，如需用则重载运算符！！
    if (&s1==&s2)
    {
        std::cout<<"Same obj!!!"<<std::endl;
    }
    return 0;
}